const db = require("../../middleware/db");
const Sequelize = require("sequelize");
// 菜单表
module.exports = sys_menu = db.define("sys_menu", {
  // 菜单名称
  name: {
    type: Sequelize.STRING(100),
    allowNull: false,
    defaultValue: "",
  },
  // 父id
  parent_id: {
    type: Sequelize.INTEGER(11).UNSIGNED,
    allowNull: true,
    defaultValue: 0,
  },
  // 图标
  icon: {
    type: Sequelize.STRING(100),
    allowNull: false,
    defaultValue: "",
  },
  path: {
    type: Sequelize.STRING(255),
    allowNull: false,
    defaultValue: "",
  },

  // 菜单类型
  type: {
    type: Sequelize.ENUM("菜单", "页面", "外链", "功能"),
    allowNull: false,
    defaultValue: "页面",
  },
  //模型id
  model_id: {
    type: Sequelize.INTEGER(11).UNSIGNED,
    allowNull: true,
    defaultValue: 0,
  },
  // 组件地址
  component: {
    type: Sequelize.STRING(100),
    allowNull: false,
    defaultValue: "",
  },

  // api地址
  api_path: {
    type: Sequelize.STRING(100),
    allowNull: false,
    defaultValue: "",
  },
  // 是否显示在菜单中
  is_show_menu: {
    type: Sequelize.INTEGER(1),
    allowNull: false,
    defaultValue: true,
  },
  is_show: {
    type: Sequelize.INTEGER(1),
    allowNull: false,
    defaultValue: true,
  },

  // 菜单类型
  sort: {
    type: Sequelize.INTEGER(11),
    allowNull: false,
    defaultValue: "0",
  },
});

// sys_menu.sync({ force: true })
